/* Copyright ©, 2022, ECARX (Hubei) Technology Co., Ltd. All rights reserved.
 *
 * NOTICE: This file contains information which is confidential and proprietary to ECARX
 * (Hubei) Technology Co., Ltd. and/or other developers. No license to any intellectual
 * property rights contained within this file is either granted or implied except as may be
 * provided in an agreement with ECARX (Hubei) Technology Co., Ltd.
 *
 * Any unauthorized copying or distribution of content from this file in whole or in part
 * is prohibited.
 */
#ifndef ECARX_VHAL_CORE_PERSIST_PROFILE_H
#define ECARX_VHAL_CORE_PERSIST_PROFILE_H

#include "Properties.h"

namespace ecarx::vhal::core::persist {

class Preference final : public Properties {
    int32_t mProfileId;
    int32_t mPreferenceId;
    std::string mPath;

public:
    Preference() = delete;
    Preference(const char *path, int32_t profileId, int32_t preferenceId);
    ~Preference();
    int32_t getPreferenceId() const;
    std::unique_ptr<Preference> cloneTo(int32_t preferenceId);
};

class Profile final : public Properties {
    int32_t mProfileId;
    std::string mPath;
    std::vector<int32_t> mCreatedPreferenceIds;
    std::unordered_map<int32_t, std::unique_ptr<Preference>> mPreferences;
    Preference* mActivePreference;

  public:
    Profile() = delete;
    Profile(const char* path, int32_t profileId);
    ~Profile();
    int32_t getProfileId() const;
    Preference* getCurrentPreference();
    bool createPreference(int32_t newPreferenceid, int32_t clonePreferenceid = 0);
    bool isCreated(int32_t preferenceId);
    bool deletePreference(int32_t preferenceId);
    bool activePreference(int32_t preferenceId);
    std::unique_ptr<Profile> cloneTo(int32_t profileId);
};

class ProfileAuxiliary final : public Properties {

  public:
    ProfileAuxiliary() = delete;
    ProfileAuxiliary(const char* path);
    ~ProfileAuxiliary();
};

}  // namespace ecarx::vhal::core::persist

#endif